/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package API;

import javax.microedition.lcdui.Font;
import javax.microedition.lcdui.Graphics;

/**
 *
 * @author mrbao
 */
public class MenuBar extends Item {

    private String left;
    private String right;
    private String center;

    public MenuBar(String left, String right, String center, int width, int height) {
        this.left = left;
        this.right = right;
        this.center = center;
        this.width = width;
        this.height = height;
        this.font = Font.getFont(Font.FACE_MONOSPACE, Font.STYLE_PLAIN, Font.SIZE_SMALL);
    }

    public int getHeight() {
        return font.getHeight();
    }

    public void SetTextLeft(String left) {
        this.left = left;
    }

    public void SetTextRight(String right) {
        this.right = right;
    }

    public void SetTextCenter(String center) {
        this.center = center;
    }

    public void Paint(Graphics g) {
        Gradient.DrawGradientBox(g, 0, height - font.getHeight(), width, font.getHeight());
        g.setColor(0xffffff);
        g.setFont(font);
        if (left != null && left.length() > 0) {
            g.drawString(left, 3, height - font.getHeight(), 0);
        }
        if (right != null && right.length() > 0) {
            g.drawString(right, width - 3, height - font.getHeight(), Graphics.RIGHT | Graphics.TOP);
        }
        if (center != null && center.length() > 0) {
            g.drawString(center, (width - font.stringWidth(center)) / 2, height - font.getHeight(), 0);
        }
    }
}
